JPA Interview Questions and Answers
Related differences
Ques 26. Mention the types of cache in JPA and their use.
There are two types of cache in JPA:
- First-level cache: Data is cached from a single transaction.
- Second-level transaction: Data is cached from more than one transaction.
Ques 27. What is the purpose of access annotation?
The access type for an entity class, embeddable, superclass, or individual attributes is defined by it. This defines the way JPA refers to entity attributes such as class properties or class fields having setters and getters.
Ques 28. What is the purpose of Basic annotation?
The simplest type of mapping of data on a column of the database is indicated by the basic annotation.
Also, the fetch field access strategy, as well as the requirement of the field, can be specified in the annotation parameters.
Ques 29. List the six types of locks available in JPA specification in ascending order.
The six types of locks are listed below in the ascending order of their reliability:
- NONE
- OPTIMISTIC
- OPTIMISTIC_FORCE_INCREMENT
- PESSIMISTIC_READ
- PESSIMISTIC_WRITE
- PESSIMISTICI
Ques 30. What options does JPA provide to set a second-level cache, or what values can be taken from the persistence.xml by the shared-cache-mode element?
The following five options are there:
- ALL
- NONE
- ENABLE_SELECTIVE
- DISABLE_SELECTIVE
- UNSPECIFIED
Most helpful rated by users:
- What is ORM in JPA?
- What is an EntityManager?
- What is the difference between persistence.xml and hibernate.cfg.xml?
- What is an Entity?
- Why to use JPA?